﻿#region Using References

using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

#endregion

namespace Beaker.OpenCube.NbtEditor.Converters
{
	class NbtIconConverter
		: IValueConverter
	{
		public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
		{
			if( targetType == typeof( ImageSource ) )
			{
				string path = null;

				if( value is IDictionary<string, object> )
					path = "NbtCompound.png";
				else if( value is string )
					path = "NbtString.png";
				else if( value is byte || value is sbyte )
					path = "NbtByte.png";
				else if( value is short || value is ushort )
					path = "NbtShort.png";
				else if( value is int || value is uint )
					path = "NbtInt.png";
				else if( value is long || value is ulong )
					path = "NbtLong.png";
				else if( value is float )
					path = "NbtFloat.png";
				else if( value is double )
					path = "NbtDouble.png";
				else if( value is byte[] || value is sbyte[] )
					path = "NbtByteArray.png";
				else if( value is int[] || value is uint[] )
					path = "NbtIntArray.png";
				else if( value is IList )
					path = "NbtList.png";

				if( path != null )
					return new Uri( "pack://application:,,,/Resources/Icons/" + path );
			}

			return null;
		}

		public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
		{
			throw new NotImplementedException();
		}
	}
}
